<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  function deepClone(obj) {
    // 处理基本类型和null
    if (obj === null || typeof obj !== 'object') {
      return obj;
    }

    // 处理Date对象
    if (obj instanceof Date) {
      return new Date(obj);
    }

    // 处理RegExp对象
    if (obj instanceof RegExp) {
      return new RegExp(obj);
    }

    // 处理Set对象
    if (obj instanceof Set) {
      const clone = new Set();
      obj.forEach(value => {
        clone.add(deepClone(value));
      });
      return clone;
    }

    // 处理Map对象
    if (obj instanceof Map) {
      const clone = new Map();
      obj.forEach((value, key) => {
        clone.set(deepClone(key), deepClone(value));
      });
      return clone;
    }

    // 处理数组或普通对象
    const clone = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj));

    for (const key in obj) {
      if (obj.hasOwnProperty(key)) {
        clone[key] = deepClone(obj[key]);
      }
    }

    return clone;
  }

  const obj = {
    a: '1',
    b: false,
    c: [1, '2'],
    d: new Date()
  }

  console.log(deepClone(obj))

</script>
</body>
</html>